/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package warmachineroster.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import warmachineroster.RosterElement;
import warmachineroster.WarmachineRosterPackage;
import warmachinesystem.BaseUnit;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Roster Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link warmachineroster.impl.RosterElementImpl#getUnitType <em>Unit Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RosterElementImpl extends EObjectImpl implements RosterElement {
	/**
	 * The cached value of the '{@link #getUnitType() <em>Unit Type</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUnitType()
	 * @generated
	 * @ordered
	 */
	protected BaseUnit unitType;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RosterElementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WarmachineRosterPackage.Literals.ROSTER_ELEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BaseUnit getUnitType() {
		if (unitType != null && unitType.eIsProxy()) {
			InternalEObject oldUnitType = (InternalEObject)unitType;
			unitType = (BaseUnit)eResolveProxy(oldUnitType);
			if (unitType != oldUnitType) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, WarmachineRosterPackage.ROSTER_ELEMENT__UNIT_TYPE, oldUnitType, unitType));
			}
		}
		return unitType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BaseUnit basicGetUnitType() {
		return unitType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUnitType(BaseUnit newUnitType) {
		BaseUnit oldUnitType = unitType;
		unitType = newUnitType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WarmachineRosterPackage.ROSTER_ELEMENT__UNIT_TYPE, oldUnitType, unitType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getPointCost() {
		return getUnitType().getPointCost();
	}

	/**
	 * <!-- begin-user-doc -->
	 * Per la maggior parte delle unità il pointValue coincide con il pointCost
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int getPointValue() {
		return getPointCost();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WarmachineRosterPackage.ROSTER_ELEMENT__UNIT_TYPE:
				if (resolve) return getUnitType();
				return basicGetUnitType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WarmachineRosterPackage.ROSTER_ELEMENT__UNIT_TYPE:
				setUnitType((BaseUnit)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WarmachineRosterPackage.ROSTER_ELEMENT__UNIT_TYPE:
				setUnitType((BaseUnit)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WarmachineRosterPackage.ROSTER_ELEMENT__UNIT_TYPE:
				return unitType != null;
		}
		return super.eIsSet(featureID);
	}

} //RosterElementImpl
